kind: ZvirtClusterConfiguration
apiVersions:
- apiVersion: deckhouse.io/v1
  openAPISpec:
    type: object
    additionalProperties: false
    description: |
      Describes the configuration of a cloud cluster in zVirt.

      Used by the cloud provider if a cluster's control plane is hosted in the cloud.

      Run the following command to change the configuration in a running cluster:

      ```shell
      kubectl -n d8-system exec -ti deploy/deckhouse -- deckhouse-controller edit provider-cluster-configuration
      ```
    x-doc-search: |
      ProviderClusterConfiguration
    x-unsafe-rules: [deleteZones]
    x-examples:
      - apiVersion: deckhouse.io/v1
        kind: ZvirtClusterConfiguration
        layout: Standard
        clusterID: "b46372e7-0d52-40c7-9bbf-fda31e187088"
        masterNodeGroup:
          replicas: 1
          instanceClass:
            numCPUs: 4
            memory: 8192
            template: debian-bookworm
            vnicProfileID: "49bb4594-0cd4-4eb7-8288-8594eafd5a86"
            storageDomainID: "c4bf82a5-b803-40c3-9f6c-b9398378f424"
        nodeGroups:
          - name: worker
            replicas: 1
            instanceClass:
              numCPUs: 4
              memory: 8192
              template: debian-bookworm
              vnicProfileID: "49bb4594-0cd4-4eb7-8288-8594eafd5a86"
        provider:
          server: '<SERVER>'
          username: '<USERNAME>'
          password: '<PASSWORD>'
          insecure: true
    required: [apiVersion, kind, sshPublicKey, clusterID, masterNodeGroup, layout, provider]
    properties:
      apiVersion:
        type: string
        enum: [deckhouse.io/v1]
      kind:
        type: string
        enum: [ZvirtClusterConfiguration]
      sshPublicKey:
        type: string
        description: a public key for accessing nodes.
      clusterID:
        type: string
        description: |
          Cluster ID with shared storage domains and CPUs of the same type to create virtual machines.
        pattern: ^[\da-fA-F]{8}\-[\da-fA-F]{4}\-4[\da-fA-F]{3}\-[\da-fA-F]{4}\-[\da-fA-F]{12}$
        example: "49bb4594-0cd4-4eb7-8288-8594eafd5a86"
      masterNodeGroup:
        type: object
        additionalProperties: false
        required: [replicas, instanceClass]
        description: |
          The definition of the master's NodeGroup.

          > Caution! After changing the parameters of the section, you need to run `dhctl converge` for the changes to take effect.
        properties:
          replicas:
            type: integer
            minimum: 1
            description: |
              The number of master nodes to create. It is important to have an odd number of masters to ensure a quorum.
            x-unsafe-rules: [updateReplicas]
          instanceClass:
            type: object
            additionalProperties: false
            required: [numCPUs, memory, template, vnicProfileID, storageDomainID]
            description: |
              Partial contents of the fields of the [ZvirtInstanceClass](https://deckhouse.ru/documentation/v1/modules/030-cloud-provider-zvirt/cr.html#zvirtinstanceclass).
            properties: &instanceClassProperties
              numCPUs:
                type: integer
                description: |
                  Number of vCPUs to allocate to the VM.
                minimum: 1
                example: 2
              memory:
                type: integer
                description: |
                  Memory in MiB to allocate to the VM.
                minimum: 1
                example: 8192
              rootDiskSizeGb:
                description: |
                  Root disk size in GiB to use in zVirt VirtualMachines.
                example: 30
                default: 30
                type: integer
              etcdDiskSizeGb:
                description: |
                  Etcd disk size in GiB.
                example: 10
                default: 10
                type: integer
              template:
                type: string
                description: |
                  Template name to be cloned.
                example: debian-bookworm
              vnicProfileID:
                type: string
                description: |
                  Virtual NIC profile ID on the basis of which the virtual NIC will be created.
                pattern: ^[\da-fA-F]{8}\-[\da-fA-F]{4}\-4[\da-fA-F]{3}\-[\da-fA-F]{4}\-[\da-fA-F]{12}$
                example: "49bb4594-0cd4-4eb7-8288-8594eafd5a86"
              storageDomainID:
                type: string
                description: |
                  Storage domain id which contains the shared resources that must be available to all datacentre hosts.
                pattern: ^[\da-fA-F]{8}\-[\da-fA-F]{4}\-4[\da-fA-F]{3}\-[\da-fA-F]{4}\-[\da-fA-F]{12}$
                example: "49bb4594-0cd4-4eb7-8288-8594eafd5a86"
      nodeGroups:
        type: array
        description: |
          An array of additional NodeGroups for creating static nodes (e.g., for dedicated front nodes or gateways).
        items:
          type: object
          required: [name, replicas, instanceClass]
          properties:
            name:
              type: string
              description: |
                The name of the NodeGroup to use for generating node names.
            replicas:
              type: integer
              description: |
                The number of nodes to create.
            nodeTemplate:
              description: |
                Parameters of Node objects in Kubernetes to add after registering the node.
              properties:
                labels:
                  type: object
                  description: |
                    A list of labels to attach to cluster resources.

                    The same as the `metadata.labels` standard [field](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#objectmeta-v1-meta).
                  x-examples:
                  - environment: production
                    app: warp-drive-ai
                  additionalProperties:
                    type: string
                annotations:
                  type: object
                  description: |
                    The same as the `metadata.annotations` standard [field](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#objectmeta-v1-meta).
                  x-examples:
                  - ai.fleet.com/discombobulate: "true"
                  additionalProperties:
                    type: string
                taints:
                  type: array
                  description: |
                    The same as the `.spec.taints` field of the [Node](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#taint-v1-core) object.

                    > **Caution!** Only the `effect`, `key`, `values`  fields are available.
                  x-examples:
                  - - effect: NoExecute
                      key: ship-class
                      value: frigate
                  items:
                    type: object
                    properties:
                      effect:
                        type: string
                        enum: [NoSchedule, PreferNoSchedule, NoExecute]
                      key:
                        type: string
                      value:
                        type: string
            instanceClass:
              type: object
              additionalProperties: false
              required: [numCPUs, memory, template, vnicProfileID]
              description: |
                Partial contents of the fields of the.
              properties:
                <<: *instanceClassProperties
      layout:
        type: string
        description: |
          The way resources are located in the cloud.

          Read [more](https://deckhouse.io/documentation/v1/modules/030-cloud-provider-zvirt/layouts.html) about possible provider layouts.
        x-unsafe: true
      provider:
        type: object
        additionalProperties: false
        description: Parameters for connecting to the Zvirt.
        properties:
          server:
            type: string
            description: The URL to the Zvirt API endpoint.
          username:
            type: string
            description: The login ID.
          password:
            type: string
            description: The user's password.
          caBundle:
            type: string
            description: CA certificate in base64.
            default: ""
          insecure:
            type: boolean
            description:  Set to `true` if Zvirt has a self-signed certificate.
            default: false
            x-doc-default: false
        required:
        - server
        - username
        - password
    oneOf:
    - required: [layout]
      properties:
        layout:
          enum:
          - Standard
          type: string
